package com.web.dao.impl;

import com.web.dao.HotelDao;
import com.web.domain.Hotel;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class HotelDaoImpl implements HotelDao {

    @Resource
    SessionFactory factory;


    public List<Hotel> searchHotel(String cityName) {
        String hql = "from Hotel t where cityName = '"+cityName+"'";
        return factory.getCurrentSession().createQuery(hql.toString()).list();
    }


    public Hotel findHotelById(Integer hotelId) {
        return (Hotel) factory.getCurrentSession().get(Hotel.class,hotelId);
    }

}
